package com.frxuexi.lib_base.http

import com.frxuexi.lib_base.entity.AddressBean
import com.frxuexi.lib_base.entity.AddressBeanItem
import com.frxuexi.lib_base.entity.CartBean
import com.frxuexi.lib_base.entity.CouponBean
import com.frxuexi.lib_base.entity.CreateOrderBean
import com.frxuexi.lib_base.entity.HomeBean
import com.frxuexi.lib_base.entity.InfoBean
import com.frxuexi.lib_base.entity.LoginBean
import com.frxuexi.lib_base.entity.MyCouponBean
import com.frxuexi.lib_base.entity.OrderBean
import com.frxuexi.lib_base.entity.OrderDetailBean
import com.frxuexi.lib_base.entity.OutOrderBean
import com.frxuexi.lib_base.entity.PinBean
import com.frxuexi.lib_base.entity.PinDetailBean
import com.frxuexi.lib_base.entity.ProductBean
import com.frxuexi.lib_base.entity.RechargeBean
import com.frxuexi.lib_base.entity.Res
import com.frxuexi.lib_base.entity.ScoreBean
import com.frxuexi.lib_base.entity.ShopBean
import com.frxuexi.lib_base.entity.ShopCommentBean
import com.frxuexi.lib_base.entity.ShopCommentNumBean
import com.frxuexi.lib_base.entity.TypeShopBean
import com.frxuexi.lib_base.entity.UserBean
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Path
import retrofit2.http.Query

interface ApiService {

    @GET("/api/front/index/product/{type}?size=10")
    suspend fun getProducts(@Path("type")type:Int,@Query("page")page:Int):Res<ProductBean>

    @POST("/api/front/sendCode")
    suspend fun senCode(@Query("phone")phone:String):Res<UserBean>

    @POST("/api/front/login/mobile")
    suspend fun login(@Body body: RequestBody):Res<LoginBean>

    @POST("/api/front/login/mobile")
    suspend fun register(@Body body: RequestBody):Res<LoginBean>

    @POST("/api/front/register/reset")
    suspend fun finPass(@Body body: RequestBody):Res<Boolean>

    @GET("/api/front/user")
    suspend fun getInfo():Res<InfoBean>

    @POST("/api/front/user/edit")
    suspend fun updateInfo(@Body body: RequestBody):Res<Any>

    @GET("/api/front/index")
    suspend fun getHomes():Res<HomeBean>

    @GET("/api/front/index/product/{type}?limit=10")
    suspend fun getProductsByType(@Path("type")type:Int,@Query("page")page:Int):Res<ProductBean>

    @GET("/api/front/category")
    suspend fun getProductsByTwoType():Res<TypeShopBean>

    @GET("/api/front/product/detail/{id}?normal=normal")
    suspend fun getShopDetail(@Path("id")id:Int):Res<ShopBean>

    @GET("/api/front/reply/config/{id}")
    suspend fun getCommentNum(@Path("id")id:Int):Res<ShopCommentNumBean>

    @GET("/api/front/reply/list/{id}")
    suspend fun getComments(@Path("id")id:Int,@Query("limit")limit:Int,@Query("page")page:Int,@Query("type")type:String):Res<ShopCommentBean>

    @GET("/api/front/products")
    suspend fun getShopByKey(@Query("cid")cid:Int,@Query("keyword")keyword:String,@Query("limit")limit:Int,@Query("page")page:Int):Res<ProductBean>

    @POST("/api/front/cart/save")
    suspend fun addCart(@Body body: RequestBody):Res<Any>

    @GET("/api/front/cart/list?isValid=true&limit=10")
    suspend fun getCarts(@Query("page") page:Int):Res<CartBean>

    @POST("/api/front/cart/num")
    suspend fun updateCart(@Query("id")id:Int,@Query("number")number:Int):Res<String>

    @POST("/api/front/cart/delete")
    suspend fun deleteCart(@Query("ids") ids:List<Int>):Res<String>

    @GET("/api/front/coupons?page=1&limit=10&type=1")
    suspend fun getCoupons():Res<CouponBean>

    @POST("/api/front/coupon/receive")
    suspend fun receiveCoupon(@Body body: RequestBody):Res<String>

    @GET("/api/front/coupon/list?type=usable&page=1&limit=10")
    suspend fun getMyCoupon():Res<MyCouponBean>

    @GET("/api/front/address/default")
    suspend fun getDefaultAddress():Res<AddressBeanItem>

    @GET("/api/front/address/list?page=1&address=20")
    suspend fun getAddress():Res<AddressBean>

    @POST("/api/front/address/edit")
    suspend fun editAddress(@Body body: RequestBody):Res<AddressBeanItem>

    @GET("/api/front/address/detail/{id}")
    suspend fun getAddressById(@Path("id")id:Int):Res<AddressBeanItem>

    @POST("/api/front/address/del")
    suspend fun deleteAddress(@Body body: RequestBody):Res<String>

    @POST("/api/front/order/create")
    suspend fun createOrder(@Body body: RequestBody):Res<CreateOrderBean>

    @GET("/api/front/order/list?limit=10")
    suspend fun getOrders(@Query("page")page:Int,@Query("type")type:String):Res<OrderBean>

    @POST("/api/front/pay/payment")
    suspend fun payOrder(@Body body: RequestBody):Res<Any>

    @GET("/api/front/order/detail/{orderId}")
    suspend fun getOrderById(@Path("orderId")orderId:String):Res<OrderDetailBean>

    @POST("/api/front/order/cancel")
    suspend fun cancelOrder(@Query("id")id:Int):Res<Any>

    @POST("/api/front/order/comment")
    suspend fun addComment(@Body body: RequestBody):Res<Any>

    @POST("/api/front/order/refund")
    suspend fun outOrder(@Body body: RequestBody):Res<Any>

    @GET("/api/front/combination/list?page=1&limit=10")
    suspend fun getPinShops():Res<PinBean>

    @GET("/api/front/combination/detail/{id}")
    suspend fun getPinDetail(@Path("id")id:Int):Res<PinDetailBean>

    @GET("/api/front/recharge/index")
    suspend fun recharge():Res<RechargeBean>

    @GET("/api/front/user/sign/list?page=1&limit=20")
    suspend fun getScores():Res<ScoreBean>
}
